import apiClient from './apiClient'

export const movieService = {
  // 分页获取影片列表
  getMovies: async (params = {}) => {
    const { page = 0, size = 10, search, categoryId } = params
    return await apiClient.get('/movies', {
      params: { page, size, search, categoryId }
    })
  },

  // 获取所有影片
  getAllMovies: async () => {
    return await apiClient.get('/movies/all')
  },

  // 根据ID获取影片
  getMovieById: async (id) => {
    return await apiClient.get(`/movies/${id}`)
  },

  // 创建影片
  createMovie: async (movieData) => {
    return await apiClient.post('/movies', movieData)
  },

  // 更新影片
  updateMovie: async (id, movieData) => {
    return await apiClient.put(`/movies/${id}`, movieData)
  },

  // 删除影片
  deleteMovie: async (id) => {
    return await apiClient.delete(`/movies/${id}`)
  },

  // 根据分类获取影片
  getMoviesByCategory: async (categoryId) => {
    return await apiClient.get(`/movies/category/${categoryId}`)
  },

  // 搜索影片
  searchMovies: async (keyword) => {
    return await apiClient.get('/movies/search', {
      params: { keyword }
    })
  },

  // 获取影片总数
  getMovieCount: async () => {
    return await apiClient.get('/movies/count')
  }
}